<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title th:text="${shop.name+'-订单管理'}"></title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;">
    <style type="text/css">
        .update {
            display: inline-block;
            margin-left: 15px;
            padding: 0 20px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            background: #009789;
            color: #fff;
            text-align: center;
            border-radius: 3px;
            cursor: pointer;
        }

        .update i {
            display: inline-block;
            margin-right: 10px;
            vertical-align: middle;
            width: 30px;
            height: 30px;
            background: url();
        }
        .T-box {
            width: 400px;
            padding: 0 20px;
            text-align: left;
        }

        .T-box p {
            position: relative;
            height: 36px;
            line-height: 36px;
            font-size: 14px;
            margin-bottom: 15px;
        }

        .T-box p span {
            display: inline-block;
            padding-right: 15px;
            text-align: right;
            width: 110px;
            line-height: 36px;
            font-size: 14px;
        }

        .T-box p input, .T-box p select {
            width: 250px;
            padding: 0 5px;
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            border: 1px solid #d3d3d3;
            outline: none;
        }

        .T-box p i {
            padding: 0 10px;
            line-height: 36px;
            font-style: normal;
        }

        .T-box p b {
            display: inline-block;
            margin-left: 10px;
            cursor: pointer;
            width: 60px;
            height: 36px;
            line-height: 36px;
            background: #c33;
            color: #fff;
            text-align: center;
            font-size: 13px;
            font-weight: normal;
        }
    </style>
    <div class="layui-tab layui-tab-brief" lay-filter="demo">
        <ul class="layui-tab-title">
            <li><a th:href="@{/shop/dashboard(shopId=${shopId})}">店铺首页</a></li>
            <li class="layui-this"><a th:href="@{/xhs/order_settle_list(shopId=${shopId})}">订单结算明细</a></li>

            <li><a href="/shop/shop_list_xhs" style="color: #9F9F9F;font-size:small;">选择店铺</a></li>
        </ul>
    </div>

    <!-- content starts -->
<!--    <blockquote class="layui-elem-quote">订单总览</blockquote>-->

    <fieldset class="layui-elem-field">
        <legend>按条件搜索</legend>
        <div class="layui-field-box">
<!--            <div class="layui-inline">-->
<!--                <form method="post" enctype="multipart/form-data" id="execl_form">-->
<!--                    <input type="file" name="excel" id="excel" placeholder="" class="layui-input">-->
<!--                </form>-->
<!--            </div>-->

<!--            <div class="layui-inline">-->
<!--                <button type="button" id="excel_upload_btn" class="layui-btn">上传excel</button>-->
<!--                <span id="excel_upload_btn_" style="display: none;" class="update"><i></i>导入中</span>-->
<!--            </div>-->
            <form class="layui-form layui-form-pane1" method="get" action="/xhs/order_list">
                <input type="hidden" name="shopId" th:value="${shop.id}" />
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <input type="text" name="orderNum" th:value="${orderNum}" placeholder="订单号" style="width: 200px;" class="layui-input">
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">结算日期</label>
                        <div class="layui-input-inline">
                            <input type="text"   class="layui-input" name="startTime" th:value="${startTime}" id="startTime" autocomplete="off"
                                  style="width: 160px;" placeholder="yyyy-MM-dd">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text"  class="layui-input" name="endTime" th:value="${endTime}" id="endTime" style="width: 160px;" autocomplete="off" placeholder="yyyy-MM-dd">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="status" id="status">
                                <option value="">交易类型</option>
                                <option th:each="item:${T(com.b2c.entity.enums.EnumXhsOrderStatus).values()}" th:value="${item.getIndex()}" th:text="${item.getName()}">等待发货</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="submit" class="layui-btn layui-btn-normal">搜索</button>
                        <i>总共：<span style="color: red" th:text="${totalSize}"></span>条记录</i>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <a th:href="@{/xhs/order_settle_import(shopId=${shop.getId()})}" class="layui-btn layui-btn-normal" >导入小红书订单结算数据</a>

                    </div>

                    <div class="layui-inline">
                        <button type="button" lass="button" id="excel_btn" class="layui-btn layui-btn-primary">导出数据</button>
                    </div>

                </div>


            </form>
        </div>
    </fieldset>

    <!-- start dd-wrapper -->
    <link rel="stylesheet" href="/goods/order.css"/>
    <div class="dd-wrapper">
        <table class="dd-table">
            <tr>
<!--                <th>ID</th>-->
                <th>订单号</th>
                <th >售后单号</th>
                <th>下单时间</th>
                <th >结算时间</th>
                <th>交易类型</th>
                <th>结算账户</th>
                <th>动账金额</th>
                <th>结算金额</th>
                <th>商品实付/实退</th>
                <th>运费实付/实退</th>
                <th>平台优惠</th>
                <th>商品税金</th>
                <th>运费税金</th>
                <th>佣金</th>
                <th>支付渠道费</th>
                <th>分销佣金</th>
                <th>花呗分期手续费</th>
                <th>备注</th>
            </tr>
            <tr th:each="item:${lists}">
<!--                <td th:text="${item.id }"></td>-->
                <td th:text="${item.getOrderNo()}"></td>
                <td th:text="${item.getAfterSaleNo()}"></td>
                <td th:text="${item.getOrderCreateTime()}"></td>
                <td th:text="${item.getOrderSettleTime()}"></td>
                <td th:text="${item.getTransactionType()}"></td>
                <td th:text="${item.getSettleAccount()}"></td>

                <td>¥<span th:text="${#numbers.formatDecimal(item.amount,1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getSettleAmount(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getGoodsAmount(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getFreightAmount(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getPlatformDiscount(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getGoodsTax(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getFreightTax(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getCommission(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getPaymentChannelFee(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getDistributionCommission(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td>¥<span th:text="${#numbers.formatDecimal(item.getHuabeiFee(),1,'COMMA',2,'POINT')  }" style="color: #FD482C;font-size: larger;"></span></td>
                <td th:text="${item.getRemark()}"></td>

            </tr>
        </table>
    </div>
    <!-- end dd-wrapper -->
    <div class="layui-box layui-laypage layui-laypage-default pageBox">
        <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
    </div>

    <script type="text/template" id="remarkBox">
        <div class="T-box">
            <p>
                <textarea name="remark" class="layui-textarea" id="remark" ></textarea>
            </p>
            <p class="T-result"><span>&nbsp;</span><em id="erro1"></em></p>
        </div>
    </script>
    <script type="text/javascript" src="/goods/Tips/Tips.min.js"></script>
    <script type="text/javascript">
        var layer;
        var $;
        var windowOpen;
        layui.use(['laydate', 'jquery', 'form', 'layer'], function () {
            var laydate = layui.laydate;
            $ = layui.jquery;
            var form = layui.form;
            layer = layui.layer;
            laydate.render({
                elem: '#startTime'
                ,type: 'date'
            });
            laydate.render({
                elem: '#endTime'
                ,type: 'date'
            });
            $(function () {
                var status = '[[${status}]]';
                $("#status").val(status);
                form.render(); //更新全部
                form.render('select'); //刷新select选择框渲染
            })


            $("#excel_btn").click(function () {
                //组合条件
                var url = "/douyin/order_list_douyin_export";
                var startTime = $("input[name=startTime]").val();
                var endTime = $("input[name=endTime]").val();
                var status = $("#status").val();
                url+="?status="+status;
                if (startTime != '') {
                    url += "&startTime=" + startTime;
                }
                if (startTime != '') {
                    url += "&endTime=" + endTime;
                }
                window.open(url, "_blank");
            })

        });

    </script>

</div>
</body>
<html>
